import { createRouter, createWebHistory, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'home',
      component: () => import('../views/Home.vue'),
    },
    {
      path: '/note/:id',
      name: 'note_detail',
      component: () => import('../views/detail/Note.vue'),
    },
    {
      path: '/topic/:id',
      name: 'topic_detail',
      component: () => import('../views/detail/Topic.vue'),
    },
    {
      path: '/recipe/:id',
      name: 'recipe_detail',
      component: () => import('../views/detail/Recipe.vue'),
    },
  ],
  scrollBehavior() {
    // 始终滚动到顶部
    return { top: 0 }
  },
})

export default router
